home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.06 Jun 88 / serial demo / GPLib.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-04-24  |  2.4 KB  |  111 lines  |  [TEXT/PJMM]

  1. UNIT GPLib;
  2.  
  3. INTERFACE
  4.  
  5.     USES
  6.         Globals;
  7.  
  8.     PROCEDURE RSerBuf (outref : integer);
  9.     PROCEDURE GoToXY (x, y : integer);
  10.     PROCEDURE Place_checkmarks (menuId, firstItem, lastItem, chosenItem : Integer);
  11.     PROCEDURE NewWindows;
  12.     PROCEDURE SelectNewWindow;
  13.  
  14. IMPLEMENTATION
  15.  
  16.             { reset the I/O variables and buffers }
  17.  
  18.     PROCEDURE RSerBuf;             {(outref : integer);}
  19.     BEGIN
  20.         IF outrefnum <> outref THEN    { reset port I/O variables and buffers }
  21.             BEGIN
  22.                 IF outrefNumA = outref THEN        {set to the 'A' buffers and variables }
  23.                     BEGIN
  24.                         outrefNum := outrefNumA;
  25.                         inrefNum := inrefNumB;
  26.                         inBuffPtr := inBuffPtrB;
  27.                         filterBuffPtr := filterBuffPtrB;
  28.                         RowA := Row;
  29.                         row := RowB;
  30.                         ColumnA := Column;
  31.                         Column := ColumnB;
  32.                         SetPort(WindowB);
  33.                         theWindow := WindowB;
  34.                     END
  35.                 ELSE
  36.                     BEGIN                            {set to the 'B' buffers and variables }
  37.                         outrefNum := outrefNumB;
  38.                         inrefNum := inrefNumA;
  39.                         inBuffPtr := inBuffPtrA;
  40.                         filterBuffPtr := filterBuffPtrA;
  41.                         RowB := Row;
  42.                         row := RowA;
  43.                         ColumnB := Column;
  44.                         Column := ColumnA;
  45.                         SetPort(WindowA);
  46.                         theWindow := WindowA;
  47.                     END;
  48.             END;
  49.     END;
  50.  
  51.                 { set the position for the next character to be displayed }
  52.  
  53.     PROCEDURE GoToXY;
  54.         VAR
  55.             I, J : integer;
  56.     BEGIN
  57.         I := x * 6;
  58.         J := y * 12 - 2;
  59.         moveto(I, J);
  60.     END;
  61.  
  62.     PROCEDURE Place_checkmarks;     {(menuId, firstItem, lastItem, chosenItem : Integer)}
  63.         VAR
  64.             index : Integer;
  65.  
  66.     BEGIN
  67.         FOR index := firstItem TO lastItem DO
  68.             checkItem(myMenus[menuID], index, False);
  69.         CheckItem(myMenus[menuID], chosenItem, True);
  70.     END;    {Place_checkmarks}
  71.  
  72.  
  73.                 { open a new window and set it's characteristics }
  74.  
  75.     PROCEDURE NewWindows;
  76.  
  77.     BEGIN
  78.         numWindows := numWindows + 1;
  79.         IF numWindows = 1 THEN                                    { modem port A }
  80.             theWindow := GetNewWindow(254, NIL, Pointer(-1));
  81.         IF numWindows = 2 THEN                                    { printer port B }
  82.             theWindow := GetNewWindow(255, NIL, Pointer(-1));
  83.         setPort(theWindow);
  84.         TextFont(monaco);
  85.         TextSize(9);
  86.         ShowWindow(theWindow);
  87.         Row := 1;
  88.         Column := 1;
  89.     END;
  90.  
  91.                 { select the window selected by the user }
  92.  
  93.     PROCEDURE SelectNewWindow;
  94.  
  95.     BEGIN
  96.         SelectWindow(whichWindow);
  97.         theWindow := whichWindow;
  98.  
  99.         IF theWindow = windowA THEN
  100.             BEGIN
  101.                 portA := true;
  102.                 RSerBuf(outrefnumA);            { reset the I/O buffers and variables }
  103.             END
  104.         ELSE
  105.             BEGIN
  106.                 portA := false;
  107.                 RSerBuf(outrefnumB);            { reset the I/O buffers and variables }
  108.             END;
  109.     END;
  110.  
  111. END.